package com.app.samba;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.app.samba.play.PlayfileActivity;
import com.app.samba.util.AppUtil;
import com.app.samba.util.FileUtils;
import com.app.samba.util.PermissionListener;
import com.app.samba.util.PermissionUtil;

import java.util.List;

/**
 * Created Date 2019/6/17
 *
 * @author liangkun
 * description：
 */
public class SwitchActivtiy extends AppCompatActivity {

    private Button btnNo;
    private Button btnReq;
    private Button btnPlay;
    private Button btnDown;
    private String path;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_switch);
        btnNo = findViewById(R.id.btn_no);
        btnReq = findViewById(R.id.btn_requ);
        btnPlay = findViewById(R.id.btn_play);
        btnDown = findViewById(R.id.btn_xiancheng);
        request();
        btnNo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SwitchActivtiy.this, MainActivity.class));
            }
        });
        btnReq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SwitchActivtiy.this, RequestNameActivtiy.class));
            }
        });
        btnPlay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SwitchActivtiy.this, PlayfileActivity.class));
            }
        });
        btnDown.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SwitchActivtiy.this, DownActivity.class));
            }
        });

    }

    private void request() {
        PermissionUtil.requestPermission(new PermissionListener() {
            @Override
            public void onGranted() {
                path = FileUtils.ROOT_PATH + AppUtil.getPackageName(SwitchActivtiy.this) + FileUtils.HEAD_PATH;
                FileUtils.createFileDir(path);
            }

            @Override
            public void onDenied(List<String> deniedPermissions) {

            }
        });
    }


}
